import React, { Component } from 'react'
import { Input, Empty, Button, Table, Tag } from 'antd';
import { Findlist } from '../../utils/api'
import { CheckCircleOutlined } from "@ant-design/icons"
import "./img.scss"
const { Search } = Input;
// main
export default class Youresult extends Component {
    state = {
        flag: true,
        list: [],
        // table
        columns: [
            {
                title: '序号',
                render: (text, recond, index) => {
                    return (index + 1)
                },
                align: "center",
            },
            {
                title: "申请人",
                dataIndex: 'name',
                key: 'name',
            },
            {
                title: "科室",
                dataIndex: 'office',
                key: 'office',
            },
            {
                title: "职位",
                dataIndex: 'type',
                key: 'type',
            },
            {
                title: "电话",
                dataIndex: 'phone',
                key: 'offphoneice',
            },
            {
                title: "审批状态",
                key: 'state',
                render: (item) => {
                    return (

                        <div>
                            {item.state == 2 && <Tag icon={<CheckCircleOutlined />} color="success">审核通过</Tag>}
                            {item.state == 3 && <Tag icon={<CheckCircleOutlined />} color="error">审核已驳回</Tag>}
                        </div>
                    )
                }
            },
        ]
    }


    onSearch = (value) => {
        Findlist({ name: value }).then(res => {
            if (res.result) {
                this.setState({
                    flag: false,
                    list: [res.result]
                })
                console.log(this.state.list)
            } else {
                this.setState({
                    flag: true
                })
            }
        })
    }
    render() {
        return (
            <div>
                <Search placeholder="请输入您的姓名" onSearch={this.onSearch} enterButton />


                {
                    !this.state.flag && <Table columns={this.state.columns} dataSource={this.state.list} pagination={{ pageSize: 7 }} />
                }
                {this.state.flag &&
                    <div className="imgbox">
                        <Empty
                            image="https://gw.alipayobjects.com/zos/antfincdn/ZHrcdLPrvN/empty.svg"
                            imageStyle={{
                                height: 500,
                            }}
                            description={
                                <span>
                                    <a>暂无数据</a>
                                </span>
                            }
                        >
                        </Empty>
                    </div>}

            </div>

        )
    }
}